<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{{asset('/layuiadmin/layui/css/layui.css')}}" media="all">
    <link rel="stylesheet" href="{{asset('/layuiadmin/style/admin.css')}}" media="all">
    
</head>
<body>

<div class="layui-fluid" style="margin-top: 0px;">
    <div class="layui-card">
        <div class="layui-card-header">修改信息</div>
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form" lay-filter="component-form-group">
                <div class="layui-form-item">
                    <label class="layui-form-label">公司名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="schoolname" lay-verify="schoolname" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">代理手机号</label>
                    <div class="layui-input-block">
                        <input type="text" name="schoolname" lay-verify="schoolname" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">联系人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="schoolname" lay-verify="schoolname" autocomplete="off" placeholder="" class="layui-input">
                    </div>
                </div>
                

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn submit site-demo-active" data-type="tabChange">保存</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<script src="{{asset('/layuiadmin/layui/layui.js')}}"></script> 
<script>
    var token = localStorage.getItem("Usertoken");
    

    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
        formSelects: 'formSelects'
    }).use(['index', 'form','upload','formSelects','element'], function(){
        var $ = layui.$ 
            ,admin = layui.admin
            ,element = layui.element
            ,form = layui.form
    // 未登录,跳转登录页面
    $(document).ready(function(){
        if(token==null){
            window.location.href="{{url('/user/login')}}"; 
        }
    });

    $.post("{{url('/api/user/user_info')}}",
        {
        token:token
        ,user_id:"{{$_GET['user_id']}}"
        },function(data){
            if(data.status == 1){
                $('.layui-form .layui-form-item').eq(1).find('input').val(data.data.phone || '');
            }else{
                layer.msg(data.message, {
                    offset: '50px'
                    ,icon: 2
                    ,time: 3000
                });
            }
    },"json");

    $('.layui-form .layui-form-item').eq(0).find('input').val("{{$_GET['user_name']}}");
    // $('.layui-form .layui-form-item').eq(1).find('input').val("{{$_GET['phone']}}");
    $('.layui-form .layui-form-item').eq(2).find('input').val("{{$_GET['logo']}}");
    console.log($('.layui-form .layui-form-item').eq(0).find('input').val("{{$_GET['user_name']}}"))
    
    $('.submit').on('click', function(){
        $.post("{{url('/api/user/up_user')}}",
        {
            token:token,
            user_id:"{{$_GET['user_id']}}",
            name: $('.layui-form .layui-form-item').eq(0).find('input').val(),
            phone: $('.layui-form .layui-form-item').eq(1).find('input').val(),
            logo: $('.layui-form .layui-form-item').eq(2).find('input').val()
        },function(res){
            console.log(res);
            if(res.status==1){
                layer.msg(res.message, {
                    offset: '50px'
                    ,icon: 1
                    ,time: 3000
                });
            }else{
                layer.alert(res.message, {icon: 2});
            }

        },"json");

    });

    });
</script>

</body>
</html>
